package de.rosmi.stuff.groovy

Object.metaClass.match { Closure c -> 
	c.call()
}

Object.metaClass.match {Object other -> 
	def propertyEqualsCounter = 0
	def propertyEqualsTotal = other.metaClass.properties.size()
	other.metaClass.properties.each {
		if (delegate.'$it'.equals(other.'$it'))	propertyEqualsCounter++ 
	}
	def totalScore = propertyEqualsCounter / propertyEqualsTotal
	return totalScore
}

Object.metaClass.match2 {Object other ->
	println other
}


args = ["./src/de/rosmi/stuff/groovy/TestObjectMatch.groovy"]

if (args) {
	def binding = new Binding()
	binding.match = Object.&match
	
	def shell = new GroovyShell(binding)
	shell.evaluate (new File(args[0]))
}
else {
	println "Usage: <script>"
}